﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace AG.Infrastructure.CabSupport
{
    public class ViewModelBase : INotifyPropertyChanged, IViewModelBase
    {
        protected bool CheckPropertyChanged<T>(string propertyName, ref T oldValue, T newValue)
        {
            if (!Equals(oldValue, newValue))
            {
                oldValue = newValue;
                RaisePropertyChanged(propertyName);
                return true;
            }
            return false;
        }

        private void RaisePropertyChanged(string name)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
